<template>
  <div class="block">
    <el-pagination
      @size-change="handleSizeChange"
      @current-change="handleCurrentChange"
      :current-page.sync="currentPage"
      :page-size="table.pageSize"
      layout="prev, pager, next, jumper"
      :total="table.totalRows">
    </el-pagination>
  </div>
</template>
<script type="text/ecmascript-6">
  let sucStatus = 200;
  export default {
    props: {
      tableList: Array,
      table: Object,
      url: String,
      queryData: String
    },
    methods: {
      handleSizeChange(val) {
        console.log(`每页 ${val} 条`);
      },
      handleCurrentChange(val) {
        this.pageNumber = val;
        this.$ajax({
          method: 'GET',
          url: this.url + '?pageSize=10&pageNum=' + this.pageNumber + this.queryData
        }).then((response) => {
          if (response.status === sucStatus) {
            this.$emit('get-table-list', response.data.data.list);
            this.$emit('get-table-data', response.data.data);
          } else {
            this.$message({
              showClose: true,
              message: response.data.message,
              type: 'error'
            });
          }
        });
      }
    },
    data() {
      return {
        currentPage: 1,
        pageNumber: 1,
        pageSize: 10
      };
    }
  };
</script>
<style lang="stylus" rel="stylesheet-stylus"></style>
